//
//  SPErrorReporter.h
//  SPKit
//
//  Created by LSP on 16/2/23.
//  Copyright © 2016年 SP. All rights reserved.
//

#import <Foundation/Foundation.h>

//#if __has_include("SPModelBase.h")
#import "SPModelBase.h"
//#endif

@class SPError;

typedef void(^ReportErrorComplete)(BOOL result, SPError *error);
typedef void(^ReportErrorHttpRequest)(SPError *error, ReportErrorComplete complete);

@interface SPErrorReporter : NSObject
@property (nonatomic, copy, readonly) NSString *storePath;
@property (nonatomic, strong, readonly) NSArray *allErrors;

-(void)setReportAction:(ReportErrorHttpRequest)reportAction;

-(void)startReport;
-(void)reportError:(SPError *)error;

-(void)saveToDisk;
@end

//#ifdef __ModelBase_h__
@interface SPError : SPModelBase
//#else
//@interface SPError : NSObject
//#endif

@property (nonatomic, assign) int64_t errorType;
@property (nonatomic, assign) NSTimeInterval creatTime;
@property (nonatomic, copy)   NSString *message;
@property (nonatomic, copy)   NSString *userID;
@property (nonatomic, assign) int64_t internalCode;
@property (nonatomic, assign) int64_t recordID;
@property (nonatomic, copy)   NSString *appVersion;

- (instancetype)initWithType:(int64_t)type userID:(NSString *)uid message:(NSString *)msg appVersion:(NSString *)version internalCode:(int64_t)internal;
+ (instancetype)errorWithType:(int64_t)type userID:(NSString *)uid message:(NSString *)msg appVersion:(NSString *)version internalCode:(int64_t)internal;
@end
